<?
/**
* Copyright (c) 2002-2007 BioWare Corp.
* http://www.bigdaddymonitor.org
*
* This file is part of the BigDaddy Monitoring
* program. It is free software distributed under
* the terms of the BSD License. It is ditributed
* in the hopes that it will be useful, but
* WITHOUT ANY WARRANTY; without event the implied
* warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE.
*
* The BSD License is available from:
* http://www.opensource.org/licenses/bsd-license.php
**/
?>
<p>Add new categories and edit existing categories</p>

<?
if ($_REQUEST["type"]=="add" || $_REQUEST["type"]=="")
{
?>

<form method="post" action="/server/query_server.php">
<table border="0" cellpadding="5" cellspacing="1" width="600" class="formtable">
<tr valign="top">
	<td class="formfielddesc">Category Name:<br />
	<span class="required">{required}</span></td>
	<td class="formfield"><input type="text" value="" name="catname" class="textfield" />
	<input type="hidden" name="action" value="addnewcategory" />
	<input type="submit" value="Add New Category" name="submit" class="submitbutton" /></td>
</tr>
</table>
</form>
<?
}
elseif ($_REQUEST["type"]=="edit")
{
	
	$catInfo["name"] = $BigDaddyData->GetCategoryNameByID($_REQUEST["catID"]);
	
?>

<form method="post" action="/server/query_server.php">
<table border="0" cellpadding="5" cellspacing="1" width="600" class="formtable">
<tr valign="top">
	<td class="formfielddesc">Category Name:<br />
	<span class="required">{required}</span></td>
	<td class="formfield"><input type="text" value="<?=$catInfo["name"];?>" name="catname" class="textfield" />
	<input type="hidden" name="action" value="editcategory" />
	<input type="hidden" name="catID" value="<?=$_REQUEST["catID"];?>" />
	<input type="submit" value="Edit Category" name="submit" class="submitbutton" /></td>
</tr>
</table>
</form>

<?
}
?>

<table border="0" cellpadding="0" cellspacing="0" width="600">
<tr valign="middle">
<td class="tableheader">
	Category
</td>
<td class="tableheader">
	Options
</td>

</tr>

<?

$aServerCategories = $BigDaddyData->GetServerCategories();

if (is_array($aServerCategories))
{

	foreach ($aServerCategories as $nIndex => $row)
	{
	?>
		<tr valign="middle">
		<td class="lineitem" width="400">
			<?=$row["name"];?>
		</td>
		<td class="lineitem" nowrap>
		<div class="buttons">
			<a href="/server/query_server.php?action=deletecategory&catID=<?=$row["ID"];?>" onClick="javascript: return confirm('Delete Category: <?=$row["name"];?>?');">delete</a>
			<a href="<?=$_SERVER["PHP_SELF"];?>?page=ServerCategory&type=edit&catID=<?=$row["ID"];?>">edit</a>
		</div>
		</td>
		</tr>
	<?
	}
}
else
{
?>
	<tr valign="middle">
		<td class="lineitem" colspan="2">
		<div align="center">
			<b>No categories available</b>
		</div>
		</td>
	</tr>
<?
}
?>
</table>
